﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using iNet.Media.Imaging.Bmp;

namespace iNet.Media.Imaging
{
	/// <summary>
	/// BMP 影像解碼工作工廠。
	/// </summary>
	public class BmpImageDecodeTaskFactory : FastImageDecodeTaskFactory
	{
		#region 建構子
		/// <summary>
		/// 初始化新的 BmpImageDecodeTaskFactory 執行個體。
		/// </summary>
		public BmpImageDecodeTaskFactory()
			: base("BMP Image DecodeTask Factory", ImageFormats.Bmp)
		{ }
		#endregion
		#region CreateDecodeTask
		public override MediaDecodeTask CreateDecodeTask(MediaStorage source)
		{
			return new BmpImageDecodeTask(source);
		}
		#endregion
		#region IsSupportedFormatCore
		protected override bool IsSupportedFormatCore(byte[] mediaHeader)
		{
			return (mediaHeader.Length >= 14 && BitConverter.LittleEndian.ToUInt16(mediaHeader) == 19778);
		}
		#endregion
		#region MediaHeaderSize
		public override int MediaHeaderSize
		{
			get
			{
				return 14;
			}
		}
		#endregion
	}
}
